Skip to content

⚡️ Golf sqrt and cbrt by getting a better initial estimate and removing an iteration#1515

Open
duncancmt wants to merge 2 commits intoVectorized:clzfrom
duncancmt:dcmt/golf-roots
Open

⚡️ Golf sqrt and cbrt by getting a better initial estimate and removing an iteration#1515
duncancmt wants to merge 2 commits intoVectorized:clzfrom
duncancmt:dcmt/golf-roots

Conversation

@duncancmt
Copy link

@duncancmt duncancmt commented Feb 27, 2026

Description

Both sqrt and cbrt can be gas optimized. sqrt only needs 6 Babylonian steps. A better initial estimate in cbrt allows us to shave a Newton-Raphson iteration later; also going down to 6.

Implementation by a meatbag. Formal proof of correctness is vibe coded.

Checklist

Ensure you completed all of the steps below before submitting your pull request:

  • Ran forge fmt?
  • Ran forge test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant